package edu.rjxy.xjdx.emps.common.utils;

import java.util.List;
public class PageInfo<T> {
    private int pageNo;// 当前页面
    private int pageSize;// 每页显示条数
    private int count;// 总行数
    private int pageCount;//总页数
    private List<T> list;
    //
    private int next; // 下一页
    private int pre;//上一页
    private boolean first;//是否第一页
    private boolean last;//是否第一页

    public PageInfo(int pageNo, int pageSize, int count, List<T> list) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.count = count;
        this.list = list;
        this.init();
    }

    private void init() {
        this.pageCount = (int)(count/pageSize) + (count%pageSize==0?0:1);
        this.first = (this.pageNo==1);
        this.last = (this.pageNo==pageCount);
        next = this.pageNo+ (last?0:1);
        pre = this.pageNo -(first?0:1);
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getPageNo() {
        return pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public int getCount() {
        return count;
    }

    public int getPageCount() {
        return pageCount;
    }

    public List<T> getList() {
        return list;
    }

    public int getNext() {
        return next;
    }

    public int getPre() {
        return pre;
    }

    public boolean isFirst() {
        return first;
    }

    public boolean isLast() {
        return last;
    }
}
/*    当前页码  pageNo
    每页显示数量 pageSize  10
        总数: count     112
        页数 ：page = (int)(count/pageSize) + (count%pageSize==0?0:1)
        limit  ? ,?    (pageNo-1)*pageSize,pageSize
*/